package com.bs.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.bs.utils.*;
import com.bs.bean.Orders;

/*持久层接口，封装了对orders表的增删改查方法功能*/
public interface OrdersMapper {

//	定义表名
	public static final String table="orders";

//  查询orders表中的所有数据
	@Select("select * from "+DBUtils.perfix+table+DBUtils.sufix+"")
	List<Orders> selectByExample(Orders orders);
	
//  根据主键id查询orders表中对应的数据
	@Select("select * from "+DBUtils.perfix+table+DBUtils.sufix+" where "+DBUtils.perfix+"id"+DBUtils.sufix+"=#{id}")
	Orders selectByPrimaryKey(Integer id);
	
//  向orders表中的添加一条数据
	@Insert("insert into "+DBUtils.perfix+table+DBUtils.sufix+" values(#{id},#{userid},#{username},#{sex},#{phone},#{instrumentid},#{name},#{rate},#{price},#{pic},#{state})")
	int insertSelective(Orders orders);

//  根据主键id更新orders表中对应的数据
	@Update("update "+DBUtils.perfix+table+DBUtils.sufix+" set "+DBUtils.perfix+"id"+DBUtils.sufix+"=#{id},"+DBUtils.perfix+"userid"+DBUtils.sufix+"=#{userid},"+DBUtils.perfix+"username"+DBUtils.sufix+"=#{username},"+DBUtils.perfix+"sex"+DBUtils.sufix+"=#{sex},"+DBUtils.perfix+"phone"+DBUtils.sufix+"=#{phone},"+DBUtils.perfix+"instrumentid"+DBUtils.sufix+"=#{instrumentid},"+DBUtils.perfix+"name"+DBUtils.sufix+"=#{name},"+DBUtils.perfix+"rate"+DBUtils.sufix+"=#{rate},"+DBUtils.perfix+"price"+DBUtils.sufix+"=#{price},"+DBUtils.perfix+"pic"+DBUtils.sufix+"=#{pic},"+DBUtils.perfix+"state"+DBUtils.sufix+"=#{state} where "+DBUtils.perfix+"id"+DBUtils.sufix+"=#{id}")
	int updateByPrimaryKey(Orders orders);
	
//  根据主键id删除orders表中对应的数据
	@Delete("delete from "+DBUtils.perfix+table+DBUtils.sufix+" where "+DBUtils.perfix+"id"+DBUtils.sufix+"=#{id}")
	int deleteByPrimaryKey(Integer id);
}